import { IPSRawItemBase } from '../ipsraw-item-base';
import { IPSRawItemParam } from '../ipsraw-item-param';
import { IPSSysCss } from '../../res/ipssys-css';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSRawItemImplBase extends PSModelObjectImpl implements IPSRawItemBase {
  get codeName(): string {
    return this.M.codeName;
  }

  get contentType(): string {
    return this.M.contentType;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psrawitemparams: IPSRawItemParam[] | null = null;

  getPSRawItemParams(): IPSRawItemParam[] | null {
    if (this.psrawitemparams == null) {
      this.psrawitemparams = this.fillChildListModel(this.M.getPSRawItemParams, 'control.IPSRawItemParam') as IPSRawItemParam[];
    }
    return this.psrawitemparams;
  }

  get psRawItemParams(): IPSRawItemParam[] | null {
    return this.getPSRawItemParams();
  }

  findPSRawItemParam(objKey: any): IPSRawItemParam | null {
    return this.getPSModel5('control.IPSRawItemParam', this.getPSRawItemParams(), objKey) as IPSRawItemParam;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定系统样式表');
    }
    return value;
  }

  get predefinedType(): string {
    return this.M.predefinedType;
  }

  get rawItemHeight(): number {
    return this.M.rawItemHeight != null ? this.M.rawItemHeight : 0.0;
  }

  get rawItemWidth(): number {
    return this.M.rawItemWidth != null ? this.M.rawItemWidth : 0.0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get templateMode(): boolean {
    return this.M.templateMode != null ? this.M.templateMode : false;
  }

  get cls(): string {
    return 'PSRawItemImplBase';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSRawItemBase') return true;
    return super.instanceof(cls);
  }
}
